package com.gudaomai.wuye.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.gudaomai.wuye.entity.CommRegion;
import com.gudaomai.wuye.mapper.CommRegionMapper;
import com.gudaomai.wuye.service.ICommRegionServ;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zenghualu
 * @since 2017-09-01
 */
@Service
public class CommRegionServImp extends BaseServiceImpl<CommRegionMapper, CommRegion> implements ICommRegionServ {

	@Autowired 
	CommRegionMapper commRegionMapper;
	
	@Override
	public boolean isExist(String code) {
		
		EntityWrapper<CommRegion> ew=new EntityWrapper<>();
		ew.setEntity(new CommRegion());
		ew.eq("code", code);
		
		CommRegion commRegion = this.selectOne(ew);
		if(null == commRegion) {
			return false;
		}
		return true;
	}

	@Override
	public boolean isValid(String code) {
		
		EntityWrapper<CommRegion> ew=new EntityWrapper<>();
		ew.setEntity(new CommRegion());
		ew.eq("code", code).notLike("is_delete", "0");
		
		CommRegion commRegion = this.selectOne(ew);
		if(null == commRegion) {
			return false;
		}
		return false;
	}
	
	@Override
	public List<CommRegion> getAllCommHouse(){
		
		List<CommRegion> commRegionHouses;

		commRegionHouses = commRegionMapper.selectAllByType("house");
		
		return commRegionHouses;
	}

	@Override
	public List<CommRegion> getAllCommPark() {
		
		List<CommRegion> commRegionParks;

		commRegionParks = commRegionMapper.selectAllByType("park");
		
		return commRegionParks;
	}

	@Override
	public List<CommRegion> getAllCommStore() {
		List<CommRegion> commRegionStores;

		commRegionStores = commRegionMapper.selectAllByType("store");
		return commRegionStores;
	}
}
